<?php
session_start();
ini_set("display_errors", 1);
error_reporting(E_ALL);

// If there is a local config, load it up and override default database 
// and other settings. File local.conf.ini should be ignored by SVN

$DB_HOST = "localhost";
$DB_USER = "vsworx_demo";
$DB_PASS = "vsworx";

$APP_ROOT_ABS_PATH = "/home/vsworx/Projects/Current/vsworxframework/Code/";
$file = '';
if (file_exists('System/local.conf.ini')) {
    $file = 'System/local.conf.ini';
}

if ($file != '') {
    $ls = parse_ini_file($file,true);
    if (isset($ls['DB']) && is_array($ls['DB'])) {
        // there is a database settings section
        if (isset($ls['DB']['DB_HOST']) && $ls['DB']['DB_HOST'] != "") {
            $DB_HOST = $ls['DB']['DB_HOST'];
        }
        if (isset($ls['DB']['DB_USER']) && $ls['DB']['DB_USER'] != "") {
            $DB_USER = $ls['DB']['DB_USER'];
        }
        if (isset($ls['DB']['DB_PASS'])) {
            $DB_PASS = $ls['DB']['DB_PASS'];
        }
    }
    if (isset($ls['SYS']) && is_array($ls['SYS'])) {
        // there is a database settings section
        if (isset($ls['SYS']['APP_ROOT_ABS_PATH']) && $ls['SYS']['APP_ROOT_ABS_PATH'] != "") {
            $APP_ROOT_ABS_PATH = $ls['SYS']['APP_ROOT_ABS_PATH'];
        }
    }
}

/* PATHS SETTINGS */
define("SITE_PATH", "http://{$_SERVER['HTTP_HOST']}/vsworxframework/");
define("APP_ROOT_ABS_PATH", $APP_ROOT_ABS_PATH);
define("SYSTEM_PATH", APP_ROOT_ABS_PATH."System/");
define("FACADE_PATH", SYSTEM_PATH."Facade/");
define("SERVICE_PATH", SYSTEM_PATH."Service/");
define("UTILS_PATH", SYSTEM_PATH."Utils/");
define("THIRD_PARTY_LIB", UTILS_PATH."ThirdParty/");
define("CONTROL_PATH", SYSTEM_PATH."Control/");
define("TEMP_PATH", SYSTEM_PATH."Temp/");
define("VALIDATION_PATH", SYSTEM_PATH."Validations/");

define("UPLOADS_PATH", APP_ROOT_ABS_PATH."Uploads/");
define("IMAGES_PATH", SITE_PATH."View/Default/Images/");
define("CSS_PATH", SITE_PATH."View/Default/Style/");

define("JS_PATH", SITE_PATH."Js/");

define("VIEW_PATH", APP_ROOT_ABS_PATH."View/");
/* PATHS SETTINGS */

/* DATABASE SETTINGS */
define("DB_HOST", $DB_HOST);
define("DB_USER", $DB_USER);
define("DB_PASS", $DB_PASS);
define("DB_NAME", "framework");
define("DB_TYPE", "mysql");
define("DSN", DB_TYPE."://".DB_USER.":".DB_PASS."@".DB_HOST."/".DB_NAME);
/* DATABASE SETTINGS */

/* OTHER SETTINGS */
define("REWRITE_URL", 1);
define("DEFAULT_PAGING_SIZE", 2);
define("CONTROLLER", "main.php");

define("DEFAULT_ACTION", "Index");
define("DEFAULT_METHOD", "UserHome");
/* OTHER SETTINGS */

/* APP SETTINGS */
define("APP_PATH", APP_ROOT_ABS_PATH."app/");
define("APP_CONTROL_PATH", APP_PATH."Control/");
define("APP_FACADE_PATH", APP_PATH."Facade/");
/* APP SETTINGS */

function pre($val) { 
	echo "<pre>";
	var_dump($val);
	echo "</pre>";
}

function prexit($val) {
	pre($val);exit;
}
?>